Lab 01 - Linux backup
Pedagogical objectives
-
Learn how to prepare an external backup disk
-
Create and restore a backup using
tar
-
Compare the preservation capabilities of
tar
andzip
Prerequisites
This lab requires an installation of Ubuntu 14.04 LTS. You can use the virtual machine you created for the ADS course last semester.
Task 1: Prepare the backup disk
In this task you will use your Linux VM to prepare an external disk that will hold backup data. It is recommended you use a USB stick that you can erase completely. For the purposes of this lab the USB stick behaves like any external disk, and we will call it a disk in the following.
If you do not have a USB stick available use your virtualization software to create a virtual disk and attach it to the Linux VM. You may have to shut down the VM before you can add a new disk. Do that only after you have done the first step below.
-
Before plugging the disk in examine the special files in the
/dev
directory that represent hard disks. List all files called/dev/hd*
/dev/sd*
Which disks and which partitions on these disks are visible?
Which partitions are mounted? Use the command
mount
without parameters to find out. -
Attach the disk to your computer.
Consult again the special files in
/dev
. Which new files appeared? These represent the disk and its partitions you just attached. -
Create a partition table on the disk and create two partitions of equal size using the
parted
tool.-
Invoke
parted
with superuser privileges. -
Invoke
parted
with a single parameter which is the special file representing the disk. Be careful not to confuse the special file for the disk (ending in a letter) and for the partitions (ending in a number). -
Display the existing partitions with the
print
command. If the disk is completely blank you will get an error message about a missing disk label. -
Use the
mktable
command to create a partition table (overwriting any existing one). It should have MBR layout (i.e. label typemsdos
). -
Display the free space with the command
print free
(roughly the size of the disk minus some overhead). Write the value down. -
Use the
mkpart
command to create the partitions.- The first partition will
- be a primary partition
- have a file system type of
fat32
- start at 0
- end at half the free space.
- The second partition will
- be a primary partition
- have a file system type of
ext4
- start at half the free space
- end at the free space.
- The first partition will
-
Quit parted and verify that there are two special files in
/dev
that correspond to the two partitions.
You can consult Gentoo Linux Documentation -- Preparing the Disks as a reference on how to use parted.
-
-
Format the two partitions using the
mkfs
command.-
The first partition has the file system type
vfat
:sudo mkfs -t vfat /dev/xxxx
-
The second partition has the file system type
ext4
.sudo mkfs -t ext4 /dev/xxxx
-
-
Create two empty directories in the
/mnt
directory as mount points, calledbackup1
andbackup2
. Mount the newly created file systems in these directories. -
How much free space is available on these filesystems? Use the
df
command with the-h
option to find out.
Task 2: Perform backups using tar and zip
In this task you will perform different backup tasks. For each write a
quick reference that you would consult as a system administrator when
you have forgotten the exact invocation of the command. Do this using
the tar
command and then using the zip
command.
The backup tasks are the following:
-
Do a backup of a user's home directory to the backup disk (VFAT partition). Create a compressed archive. How do you ensure that the files in the archive have the proper path so that you can restore them later to any place?
-
List the content of the archive.
-
Do a restore of the archive to a different place, say
/tmp
. -
Do an incremental backup that saves only files that were modified after, say, September 18, 2015, 10:42:33. Do this only for
tar
, not forzip
.-
Use the
find
command to determine the files that should be included in the backup. -
Use
tar
's-T
option to read the names of the files to be archived from a file.
-
Task 3: Backup of file metadata
In this task you will examine how well the backup commands preserve
file metadata. Consult the man pages and perform tests using tar
and
zip
and examine whether you can restore:
- the last modification time
- the permissions
- the owner
In the lab report describe the tests you did and their results.
Task 4: Symbolic and hard links
In this task you will examine whether the backup commands preserve
symbolic and hard links. Consult the man pages and perform tests using
tar
and zip
. In the lab report describe the tests you did and
their results.
Lab deliverables
Write your lab report in plain text (.txt) or a word processor format (ODF, Word), or PDF. Plain text is preferred.
Put the report into the shared folder at \\eistore1.einet.ad.eivd.ch\cours\tic\MGF\AIT\Rendus. Organize your submissions in folders like so:
- folder
albert.einstein
(your user id)- folder
lab01
- file
report.txt
- file
- folder
Lab due date
Deliver your results at the latest 15 minutes before the start of the next lesson.